package com.toolset.Activity.UserItemActivity;

import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

import com.toolset.Activity.BaseActivity;
import com.toolset.Activity.LoginActivity;
import com.toolset.Controller.ActivityController;
import com.toolset.R;
/*
退出登陆
 */
public class Logout extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_logout);

        Toast.makeText(Logout.this,"正在退出~",Toast.LENGTH_LONG).show();

        //设置弹出对话框
        AlertDialog dialog = new AlertDialog.Builder(this).create();

        dialog.setTitle("您确定要退出吗？");//设置对话框标题

        dialog.setMessage("如果确定退出,则跳转登录界面！");//设置文字显示内容

        //设置确定按钮操作
        dialog.setButton(DialogInterface.BUTTON_POSITIVE,"确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                //清空所有活动
                ActivityController.finishAll();
                Toast.makeText(Logout.this,"退出成功！跳转登陆页~",Toast.LENGTH_LONG).show();

                //跳转登录页
                Intent intent = new Intent(Logout.this,LoginActivity.class);
                startActivity(intent);
            }
        });

        //设置取消按钮操作
        dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();//关闭对话框
                //关闭该活动
                finish();
            }
        });;

        dialog.show();//显示对话框

    }
}
